#!/usr/bin/env python
# -*- coding: UTF-8 -*-

valid_flag = 15  # 0x1111 lon ,lat, dir, rtk


class GPSStruct:
    def __init__(self):
        self.lontitude = float(0.0)
        self.latitude = float(0.0)
        self.direct = float(0.0)
        self.mode = ''
        self.altitude = float(0.0)
        self.utc = None
        self.velocity = 0.0
        self.valid = 0

    def isvalid(self):
        if self.valid & valid_flag == valid_flag:
            return True

    def setlon(self, lon):
        self.lontitude = lon
        self.valid = self.valid ^ (1 << 3)

    def setlat(self, lat):
        self.latitude = lat
        self.valid = self.valid ^ (1 << 2)

    def setdirect(self, direct):
        self.direct = direct
        self.valid = self.valid ^ (1 << 1)

    def setmode(self, mode):
        self.mode = mode
        self.valid = self.valid ^ 1

    def setalti(self, alt):
        self.altitude = alt

    def setutc(self, utc):
        self.utc = utc

    def setvelocity(self, vel):
        self.velocity = vel

    def reset(self):
        self.valid = 0x000
